<html>
<head>
<link rel="stylesheet" type="text/css" href=<?php echo base_url()."zy.css"; ?> />
<title>查询结果</title>
<style type="text/css">
	.my_clip_button { text-decoration:underline; color:blue; }
	.my_clip_button.hover { background-color:#eee; }
	.my_clip_button.active { background-color:#aaa; }
</style>
<script type="text/javascript" src=<?php echo base_url()."jquery.js"; ?> ></script>
<script type="text/javascript" src=<?php echo base_url()."ZeroClipboard/ZeroClipboard.js"; ?> ></script>
<SCRIPT LANGUAGE="JavaScript">
var clips = new Array;

function init() {
	for (i = 0; i < 10; i++)
	{
		clip = new ZeroClipboard.Client();
		clip.setHandCursor( true );
		clip.idstr = "txt" + i;
		
		clip.addEventListener('load', function (client) {
	
		});
		
		clip.addEventListener('mouseOver', function (client) {
			// update the text on mouse over
			client.setText( $("#"+client.idstr).val() );
		});
		
		clip.addEventListener('complete', function (client, text) {

		});

		clip.glue( 'd_clip_button'+i, 'd_clip_container'+i );
		
		clips.push(clip);
	}
}

function popUp(URL) {
var width=Math.round((window.screen.width-800)/2);
var height=Math.round((window.screen.height-600)/2);
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=1,width=800,height=600,top="+height+",left="+width+"');");
}
</script>
</head>
<body onLoad="init()">
<center>
<?php
	$this->load->library('myphplib');
	myphplib::myheadlinks();
?>
<br />
<br />
<br />
<h1>
查询结果--
<?php
	echo "共找到"."$resultnum"."个结果   "; 
	echo '<a href='.base_url().'index.php?c=zy&m=export_search&search_method='.$search_method.'&search_key='.$search_key.'>导出EXCEL</a>';
?>
</h1>

<?php
	$mynumber = 0;

	echo '<table cols="100" border="1" width="800"';
	
	if (!$table_bgcolor || !strcmp($table_bgcolor, "none"))
	{
		echo ">\n";
	}
	else
	{
		echo "style=background-color:".$table_bgcolor.">\n";
	}
?>
<?php foreach($queryresult->result() as $row):?>
  <tr>
    <td style="background-color:gray" width="80">姓名</td>
    <td>
    <?php
    	$url = base_url()."index.php?c=zy_search&m=dosearch&search_method=name&search_key=";
    	$url .= str_replace(chr(32),'&nbsp;',addslashes(htmlspecialchars($row->name)));
    	$url .= "&per_page=0";
    	echo "<a href=$url>";
    	echo str_replace(chr(32),'&nbsp;',addslashes(htmlspecialchars($row->name)));
    	echo " </a>";
    ?>
    </td>
    <td style="background-color:gray">性别</td><td><?php echo (!strcmp($row->sex, 'M') ? "男性" : "女性"); ?></td>
    <td style="background-color:gray">年龄</td><td><?php echo ($row->age < 0) ? ($row->age + 1000)."月" : $row->age."岁"; ?></td>
    <td style="background-color:gray">日期</td>
    <td>
    <?php
    	$url = base_url()."index.php?c=zy_search&m=dosearch&search_method=date&search_key=";
    	$url .= $row->date;
    	$url .= "&per_page=0";
    	echo "<a href=$url>";
    	echo $row->date;
    	echo " </a>";
    ?>
    </td>
    <td width="40">
    	<?php
			echo '<div id="d_clip_container'.$mynumber.'" style="position:relative">';
			echo '<div id="d_clip_button'.$mynumber.'" class="my_clip_button">复制</div>';
			$sexstr = !strcmp($row->sex, 'M') ? "男，" : "女，";
			$agestr = ($row->age < 0) ? ($row->age + 1000)."月，" : $row->age."岁，";
			$datestr = "";
			if (!strcmp($row->attackdate, "0000-00-00"))
			{
				$datestr = $row->date."来诊\n";
			}
			else
			{
				$datestr = $row->attackdate."发病，".$row->date."来诊\n";
			}
			$content = $row->name."，".$sexstr.$agestr.$datestr.$row->diag."\n".$row->prescribe."\n".$row->usemethod."\n".$row->comment;
			echo '<textarea name="txt'.$mynumber.'" rows="5" cols="20" style="display:none" id="txt'.$mynumber.'">'.$content.'</textarea>';
    	$mynumber++;
    	?>
    </td>
    <td width="40"><?php echo "<a href=".base_url()."index.php/zy_caselist/printcase/".$row->index." target='_blank' />"; ?>打印</td>
    <td width="40"><?php echo "<a href=".base_url()."index.php/zy_caselist/second/".$row->index." />"; ?>复诊</td>
    <td width="40"><?php echo "<a href=".base_url()."index.php/zy_caselist/modify/".$row->index." />"; ?>修改</td>
    <td width="40"><?php echo "<a href=".base_url()."index.php/zy_caselist/delete/".$row->index." />"; ?>删除</td>
  </tr>
	<tr>
	<td>联系电话</td>
	<td colspan=""><?php echo str_replace(chr(32),'&nbsp;',addslashes(htmlspecialchars($row->phonenum))); ?></td>
	<td>住址</td>
	<td colspan="11"><?php echo nl2br(htmlentities($row->addr)); ?></td>
	</tr>
	<tr>
	<td>发病日期</td>
	<td colspan="13"><?php echo nl2br(htmlentities($row->attackdate)); ?></td>
	</tr>	
  <tr height="100">
    <td>病史</td><td colspan="13"><?php echo nl2br(htmlentities($row->diag)); ?></td>
  </tr>
  <tr height="50">
    <td>处方</td><td colspan="13"><?php echo nl2br(htmlentities($row->prescribe)); ?></td>
  </tr>
  <tr height="50">
    <td>煎煮法</td><td colspan="13"><?php echo nl2br(htmlentities($row->usemethod)); ?></td>
  </tr>
  <tr height="50">
    <td>备注</td><td colspan="13"><?php echo nl2br(htmlentities($row->comment)); ?></td>
  </tr>
  <td>文件列表</td>
  <td colspan="13">
  <?php
  	$browseflag = 0;
  	$files = explode(";", $row->files);

  	for ($i = 0; $i < count($files); $i++)
  	{
  		if (!strcmp($files[$i], ""))
  		{
  			continue;	
  		}

  		$fileurl = base_url().$this->load->get_var('uploaddir')."/$files[$i]";
  		echo "<a href=$fileurl>$files[$i]</a><br/>";
  		$browseflag = 1;
  	}

		if ($browseflag)
		{
			$url = base_url().'index.php/zy_caselist/showpictures/'.$row->index;
			echo '<A HREF=javascript:popUp("'.$url.'")>'."浏览全部</A>";
		}
  ?>
  </td>
  </tr>
<?php endforeach;?>
</table>
<br />
<br />
<?php echo $this->pagination->create_links(); ?>
</center>
</body>
</html>